$def with (word, game, players, guesses, player_me, player_turn, range, states)
<script type="text/javascript" src="static/prototype.js"></script>
<p>Мое слово <b>$word</b></p>
<p>Мои догадки
<table border=1>
<tr>
<td />
$for p in players:
    <td>$p['id']</td>
</tr>
$for g in range:
    <tr>
    <td>$guesses[g]</td>
    $for p in players:
    <td>$p['mine'][g]</td>
    </tr>
</table>
</p>
<p>Догадки соперников
<table border=1>
$for p in players:
    <tr>
    <td>
    $p['id']
    <!--  0 == Player.TURN -->
    $if 0 == p['id']:
        (turn)
    </td><td>
    $for g in p['his']:
        $g[0] ($g[1])
    </td>
    </tr>
</table>
</p>
<style type="text/css">
td[state='0'] {background-color: yellow}
td[state='1'] {background-color: red}
td[state='2'] {background-color: #00ff00}
td[state='3'] {background-color: blue}
</style>
<p>Буковки
<table border=1 cellpadding=7>
<td>
$for state in states:
    <td id='td$state[2]' state='$state[1]'>$state[0]</td>
</td>
</table>
</p>
<script type="text/javascript">
$for state in states:
    \$('td$state[2]').observe('click', colors)
function colors(event) {
  var element = event.element();
  var state = parseInt(element.readAttribute('state')) + 1;
  if (state == 4) {
    state = 0;
  }
  element.setAttribute('state', state);
  switch (state) {
    case 0:
      element.setStyle({backgroundColor: 'yellow'});
      break;
    case 1:
      element.setStyle({backgroundColor: 'red'});
      break;
    case 2:
      element.setStyle({backgroundColor: '#00ff00'});
      break;
    case 3:
      element.setStyle({backgroundColor: 'blue'});
      break;
  }
  new Ajax.Request("/ajax/state/$player_me/"
                  + element.id
                  + "-"
                  + state, {method: 'get'});
}
</script>
<p>Угадать
<form method="post" action="move">
<input type="text" name="word" />
<input type="hidden" name="game" value="$game" />
<input type="hidden" name="player" value="$player_me" />
<input type="submit" value="Давай!"
$if player_me != player_turn:
    disabled="true"
$else:
    style="background-color: #5F5;"
/>
</form>
</p>
$if player_turn != player_me:
    <script language="javascript">
    new PeriodicalExecuter(
      function(pe) {
        new Ajax.Request("/ajax/game_state/$player_me", {
          method: 'get',
          onSuccess: function(transport) {
            // 0 == Player.TURN
            if (transport.responseText == 0) {
              pe.stop();
              location.reload('true');
            }
          }
        });
      },
      5
    );
    </script>
